<?php
/* @var $this HomeController */
/* @var $dataProvider CActiveDataProvider */
$city = 'Новосибирск'
?>
<?php $Params = array( 'zc'=>1,/* зоом с вырезанием */); ?>
<h1><?php echo $this->_h1?></h1>
<?php //echo '<pre>'.print_r($this).'</pre>'?>
<?php // echo '<pre>'.print_r($dataProvider->getData(), 1).'</pre>'; ?>
<?php $this->renderPartial('/site/_filter_catalog', array('filter'=>$filter));?>
<div class="list_ads">
<?php $models = $dataProvider->getData(); ?>
<?php foreach ($models as $i => $model) { ?>
<?php $h1 = $model->getH1(); ?> 
	<div class="ad_p">
		<div class="inf_p">	
			<?php $photos = $model->homePhotoses; 
			if (count($photos)) {
				$firstPhoto = $photos[0];
				$src = Home::getFolder($firstPhoto->path, false).$firstPhoto->path;
				//if (file_exists($src))
				$srcSmall = ImageResizer::resizeImage($src, array('w'=>235, 'h'=>150), 0, $Params, 'catalog');
			?>
			<div class="image">
			<a class="full-link" href="<?php echo $this->createUrl('home/view',array('city'=>'nsk', 'id'=>$model->id));?>">
				<?php echo CHtml::image($srcSmall ? $srcSmall : $src);?>
			</a>
			<?php $count = count($photos);?>
			<?php if ($count - 1 > 0) { ?><span><?php echo $count?> фото</span><?php } ?>
			</div>
			<?php } ?>			
			<div class="inf_text">
				<table>
				<tr class="tp">
					<td colspan="3"><a class="full-link" href="<?php echo $this->createUrl('home/view',array('city'=>'nsk', 'id'=>$model->id));?>"><?php echo $h1; ?></a></td>
					<td class="price" colspan="1"><label><b><?php echo number_format($model->cost, 0, '.', ' ');?></b> руб/мес</label></td>
				</tr>
				<tr>
					<td><div><img src="<?php echo Yii::app()->request->baseUrl; ?>/images/ico/1.png"/></div><?php echo $model->area ?> м<sup>2</sup></td>
					<td><div><img src="<?php echo Yii::app()->request->baseUrl; ?>/images/ico/2.png"/></div><?php echo $model->furniture > 0 ? 'Есть' : 'Нет'?></td>
					<td><div><img src="<?php echo Yii::app()->request->baseUrl; ?>/images/ico/3.png"/></div><?php echo $model->wash_machine > 0 ? 'Есть' : 'Нет'?></td>
					<td class="last"><div><img src="<?php echo Yii::app()->request->baseUrl; ?>/images/ico/4.png"/></div><a class="ya_click" id="<?php echo md5($model->id)?>"><?php echo $model->address?></a></td>
				</tr>
				<tr>
					<td>
					<?php if ($model->floor > 0) { ?>
					<div><img src="<?php echo Yii::app()->request->baseUrl; ?>/images/ico/5.png" title="Этаж"></div><?php echo $model->floor.($model->max_floor>0 ? '/'.$model->max_floor : '')?> этаж
					<?php } ?>
					</td>
					<td><div><img src="<?php echo Yii::app()->request->baseUrl; ?>/images/ico/6.png"/></div><?php echo $model->cooker > 0 ? 'Есть' : 'Нет'?></td>
					<td><div><img src="<?php echo Yii::app()->request->baseUrl; ?>/images/ico/7.png"/></div><?php echo $model->fridge > 0 ? 'Есть' : 'Нет'?></td>
					<td class="last">
						<div><img src="<?php echo Yii::app()->request->baseUrl; ?>/images/ico/8.png"/></div>
						<?php if (!$showPhone) { ?>
						<label class="phon_e"><a href="<?php $this->createUrl('pay')?>">Показать номер</a><span></span></label>
						<?php } else { ?>
							<?php $spanId = 'phone_'.$model->id ?>
							<label class="phon_e" id="<?php echo $spanId?>"><?php echo CHtml::link('Показать номер', '#', array(
							    'ajax' => array(
								    'type'=>'POST', 
								    'url'=>$this->createUrl('home/phone', array('id'=> $model->id)),
								    'update'=>'#'.$spanId, 
								    'data'=>array('id'=>$model->id,'YII_CSRF_TOKEN' => Yii::app()->request->csrfToken),
							 	 ),
							));?>
							</label>
						<?php } ?>	
					</td>
				</tr>
			</table>
			</div>	
			<div class="clr"></div>
		</div>
	<?php ?>
	<div class="full" id="full_<?php echo md5($model->id)?>">
	<?php /*?><div class="text">
	Vestibulum ac diam sit amet quam vehicula elementum sed sit amet dui. Quisque velit nisi, pretium ut lacinia in, elementum id enim. Mauris blandit aliquet elit, eget tincidunt nibh pulvinar a. Curabitur arcu erat, accumsan id imperdiet et, porttitor at sem. Vestibulum ac diam sit amet quam vehicula elementum sed sit amet dui. Proin eget tortor risus. Vivamus magna justo, lacinia eget consectetur sed, convallis at tellus. Nulla porttitor accumsan tincidunt. Pellentesque in ipsum id orci porta dapibus. Curabitur arcu erat, accumsan id imperdiet et, porttitor at sem.
	</div>
	<div class="pab">
	<div class="photos">
	<ul>
	<li><img src="images/kv.jpg" alt="" title=""/></li>
	<li><img src="images/kv.jpg" alt="" title=""/></li>
	<li><img src="images/kv.jpg" alt="" title=""/></li>
	</ul>
	</div>
	<a class="zk" href="#">Подать заявку</a>
	<div class="clr"></div>
	</div>*/?>
	<?php $this->renderPartial('yandex_map',array(
		'model' => $model,
		'width' => 888,
		'height' => 400,
		'isWindow' => false,
	));?>
	</div>
	<?php  ?>
</div>
<?php } ?>
<?php if (!count($models)) { ?>
<span>По Вашему запросу <b>результатов не найдено</b>. Попробуйте выбрать другие параметры.</span>
<?php } ?>
</div>
<?php if (isset($pages) && $pages->pageCount > 1) { ?>
<div class="pagination">
	<?php $this->widget('CLinkPager', array(
		'pages' => $pages,
		'maxButtonCount' => 5,
		'prevPageLabel' => 'Назад',
		'nextPageLabel' => 'Вперед',
		'lastPageLabel' => 'Конец',
		'firstPageLabel' => 'Начало',
		'header' => '',
	))?>
</div>
<?php } ?>